﻿CREATE PROCEDURE [dbo].[proc_CallCenter_Record_Getlast1]
	(
		@CompanyId int,
		@TxtFileName nvarchar(50)
	    ,@zuoxiType int
	)
AS
declare @tempDate datetime  
 
 if @zuoxiType =10001 --客服
   begin
    Set @tempDate=Isnull((Select Top 1 EndDate From CallCenter_Record Where CompanyId=@CompanyId and TxtFileName=@TxtFileName and ZuoxiID>10000   Order by EndDate DESC),'1900-01-01') --ORDER 由ID变更为EndDate 以避免最后一条取到的时间数据不是最大时间导致的数据重复
	 Select @tempDate
	 RETURN
	end
 else  if @zuoxiType=9999 --销售
   begin
    Set @tempDate=Isnull((Select Top 1 EndDate From CallCenter_Record Where CompanyId=@CompanyId and TxtFileName=@TxtFileName and ZuoxiID<10000   Order by EndDate DESC),'1900-01-01') --ORDER 由ID变更为EndDate 以避免最后一条取到的时间数据不是最大时间导致的数据重复

    Select @tempDate
	RETURN
   end

 